package com.example.web;

import com.example.util.YmlUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
public class TestController {
    @Value("${server.port}")
    public Integer port;

    @GetMapping("/port")
    public Integer getPort() {
        return port;
    }

    @GetMapping("/edit")
    public String edit() {
        try {
            YmlUtil.editYmlByKey("server.port", 8888);
            return "ok";
        } catch (IOException e) {
            e.printStackTrace();
            return "no";
        }
    }
}
